﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace RefOffPDA
{
    /*
     * Class: ExtraTime
     * 
     * Use: Form displayed when user chooses to play a period of extra time
     * 
     * Author: Mike Skaife, mcs3@aber.ac.uk
     */
    public partial class ExtraTime : Form
    {
        //Get hold of the current match object
        Match theMatch;
        
        public ExtraTime(Match match)
        {
            InitializeComponent();
            theMatch = match;
        }
                
        //This code is run when the 'Classic' button is clicked
        //Sets up a standard period of extra time - 2 x 15 mins
        private void extraClassicBtn_Click(object sender, EventArgs e)
        {
            //Indicate match is now into classic extra time
            theMatch.isExtraTime = true;
            
            //Set the timer to '00:00'
            theMatch.tenMinutes = 0;
            theMatch.minutes = 0;
            theMatch.tenSeconds = 0;
            theMatch.seconds = 0;
            theMatch.MatchTimerLLbl.Text = "" + theMatch.tenMinutes + theMatch.minutes + ":" + theMatch.tenSeconds + theMatch.seconds;
            
            //Close this form and display the main Match screen
            theMatch.Visible = true;
            this.Visible = false;
        }

        //This code is run when the 'Golden Goal' button is clicked
        //Runs 2 x 15 mins until a goal is scored, when the match ends
        private void extraGoldenBtn_Click(object sender, EventArgs e)
        {
            //Indicate that match is now into golden goal extra time
            theMatch.isExtraTime = true;            
            theMatch.homeGoal.isGoldenGoal = true;
            theMatch.awayGoal.isGoldenGoal = true;

            //Set timer to '00:00'
            theMatch.tenMinutes = 0;
            theMatch.minutes = 0;
            theMatch.tenSeconds = 0;
            theMatch.seconds = 0;
            theMatch.MatchTimerLLbl.Text = "" + theMatch.tenMinutes + theMatch.minutes + ":" + theMatch.tenSeconds + theMatch.seconds;
            
            //Close this form and display the main Match screen
            theMatch.Visible = true;
            this.Visible = false;
        }

        //This code is run when the 'Cancel' button is clicked
        private void cancelBtn_Click(object sender, EventArgs e)
        {
            //Restart timer, etc.
            theMatch.returnFromCancelEndMatch();

            //Close this form and display the main Match screen
            theMatch.Visible = true;
            this.Visible = false;
        }
    }
}